package goylc

/////////////////////////////////// raw ///////////////////////////////////////
type GoylcSet struct {
	container map[interface{}]struct{}
}

func (set *GoylcSet) Add(some interface{}) {
	set.container[some] = struct{}{}
}

func (set *GoylcSet) Clear() {
	set.container = map[interface{}]struct{}{}
}

func (set *GoylcSet) Remove(some interface{}) {
	delete(set.container, some)
}

func (set *GoylcSet) Get(some interface{}) (interface{}, bool) {
	v, ok := set.container[some]
	return v, ok
}

func (set *GoylcSet) Len() int64 {
	size := int64(len(set.container))
	return size
}

func (set *GoylcSet) Pop() interface{} {
	var val interface{} = nil
	for k, _ := range set.container {
		val = k
		break
	}

	set.Remove(val)

	return val
}

func NewGoylcSet() *GoylcSet {
	return &GoylcSet{
		container: make(map[interface{}]struct{}, 10),
	}
}
